﻿@model ePrice.Models.Category

@{
    ViewBag.Title = "Category";
}

<h2>Category</h2>

@{
	if (!ViewBag.ListMode) 
	{
		if (Model != null)
		{
			if (Model.Products != null)
			{
				int count = 1;
				<table> 
					<tr> 
						<th> 
							No. 
						</th> 
						<th> 
							Product ID 
						</th> 
						<th> 
							Product Name 
						</th> 
					</tr>
					@foreach(ePrice.Models.Product product in Model.Products) { 
					<tr> 
						<td> 
							@count
						</td> 
						<td> 
							@Html.DisplayFor(modelItem => product.ProductId) 
						</td> 
						<td> 
							@Html.DisplayFor(modelItem => product.ProductName) 
						</td> 
					</tr>
					count++;
					}
				</table>
				<br />
			}
			else
			{
				<p>Notice!</p>
				<p>This category doesn't have any products yet!</p>
			}
		}
		else
		{
			<p>Notice!</p>
			<p>No such category was found on the server!</p>
		}
	}
	else
	{
		<ul>
			@foreach(ePrice.Models.Category category in ViewBag.List)
			{
				<li>
				@Html.ActionLink(category.CategoryName, "Category", "Product", new { id = category.CategoryId }, "")
				</li>
			}
		</ul>
	}
}